package cn.core.tool.aviator;

import com.googlecode.aviator.AviatorEvaluator;
import com.googlecode.aviator.AviatorEvaluatorInstance;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 表达式引擎实例配置
 */
@Configuration
public class AviatorEvaluatorInstanceConfig {

  @Bean
  public AviatorEvaluatorInstance aviatorEvaluatorInstance() {
    AviatorEvaluatorInstance aviatorEvaluatorInstance = AviatorEvaluator.getInstance();
    aviatorEvaluatorInstance.addFunction(new AddFunc());
    aviatorEvaluatorInstance.addFunction(new SubFunc());
    aviatorEvaluatorInstance.addFunction(new MulFunc());
    aviatorEvaluatorInstance.addFunction(new DivFunc());
    aviatorEvaluatorInstance.addFunction(new LogFunc());
    return aviatorEvaluatorInstance;
  }

}
